<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
<!--    <meta http-equiv="X-UA-Compatible" content="IE=edge">-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes" />
    <title>汽车租赁</title>
    <meta name="description" content="汽车租赁">
    <meta name="keywords" content="汽车租赁">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<style>
    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }
    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }
    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }
</style>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>还车管理<small>还车列表</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>还车管理</el-breadcrumb-item>
            <el-breadcrumb-item>还车列表</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="filter-container">
                订单编号：<el-input placeholder="订单编号" v-model="pagination.orderId" style="width: 200px;" class="filter-item"></el-input>
                下单人：<el-input placeholder="下单人" v-model="pagination.memberName" style="width: 200px;" class="filter-item"></el-input>
                下单人手机号：<el-input placeholder="下单人手机号" v-model="pagination.phoneNumber" style="width: 200px;" class="filter-item"></el-input>
                车辆名称：<el-input placeholder="车辆名称" v-model="pagination.carName" style="width: 200px;" class="filter-item"></el-input>
                <el-button @click="findPage()" class="dalfBut">查询</el-button>
            </div>
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="returnId" label="还车编号" align="center"></el-table-column>
                <el-table-column prop="orderId" label="订单编号" align="center"></el-table-column>
                <el-table-column prop="shopName" label="店铺名称" align="center"></el-table-column>
                <el-table-column prop="phoneNum" label="店铺手机号" align="center"></el-table-column>
                <el-table-column prop="memberName" label="下单人" align="center"></el-table-column>
                <el-table-column prop="phoneNumber" label="下单人手机号" align="center"></el-table-column>
                <el-table-column prop="carName" label="车辆名称" align="center"></el-table-column>
                <el-table-column prop="plateNumber" label="车牌号" align="center"></el-table-column>
                <el-table-column prop="dailyRent" label="车辆价格" align="center"></el-table-column>
                <el-table-column prop="deposit" label="车辆押金" align="center"></el-table-column>
                <el-table-column prop="orderDate" label="预计租车时间" align="center"></el-table-column>
                <el-table-column prop="returnDate" label="预计还车时间" align="center" ></el-table-column>
                <el-table-column prop="trueOrderDate" label="实际租车时间" align="center" ></el-table-column>
                <el-table-column prop="trueReturnDate" label="实际还车时间" align="center" ></el-table-column>
                <el-table-column prop="compensationAmount" label="赔付金额" align="center" ></el-table-column>
                <el-table-column  label="磨损验证图片" width="100" align="center">
                    <!--插入图片链接的代码-->
                    <template slot-scope="scope">
                        <img :src="scope.row.returnImageone" alt style="width: 50px;height:50px">
                    </template>
                </el-table-column>
                <el-table-column  label="磨损验证图片" width="100" align="center">
                    <!--插入图片链接的代码-->
                    <template slot-scope="scope">
                        <img :src="scope.row.returnImagetwo" alt style="width: 50px;height:50px">
                    </template>
                </el-table-column>
                <el-table-column  label="磨损验证图片" width="100" align="center">
                    <!--插入图片链接的代码-->
                    <template slot-scope="scope">
                        <img :src="scope.row.returnImagethree" alt style="width: 50px;height:50px">
                    </template>
                </el-table-column>
                <el-table-column  label="磨损验证图片" width="100" align="center">
                    <!--插入图片链接的代码-->
                    <template slot-scope="scope">
                        <img :src="scope.row.returnImagefour" alt style="width: 50px;height:50px">
                    </template>
                </el-table-column>
                <el-table-column  label="磨损验证图片" width="100" align="center">
                    <!--插入图片链接的代码-->
                    <template slot-scope="scope">
                        <img :src="scope.row.returnImagefive" alt style="width: 50px;height:50px">
                    </template>
                </el-table-column>

                <el-table-column prop="returnState" label="状态" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.returnState == 0">未还车</span>
                        <span v-if="scope.row.returnState == 1">已还车</span>
                    </template>
                </el-table-column>


                <el-table-column label="操作" align="center" width="200px">
                    <template slot-scope="scope">
                        <el-button size="mini" type="success" @click="handleEdit(scope.row)">编辑</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.pageIndex"
                        :page-size="pagination.pageSize"
                        :page-sizes="[5, 10, 20, 50]"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>

            <!-- 编辑标签弹层 -->
            <div class="add-form">
                <el-dialog title="编辑订单" :visible.sync="dialogFormVisible4Edit">
                    <template>
                        <el-tabs v-model="activeName" type="card">
                            <el-tab-pane label="订单列表" name="first">
                                <el-form label-position="right" label-width="130px">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="上传图片1">
                                                <el-upload
                                                        class="avatar-uploader"
                                                        action="/file/avatarUpload"
                                                        :auto-upload="autoUpload"
                                                        name="imgFile"
                                                        :show-file-list="false"
                                                        :on-success="handleAvatarSuccessOne"
                                                        :before-upload="beforeAvatarUpload">
                                                    <img v-if="imageUrl1" :src="imageUrl1" class="avatar">
                                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                                </el-upload>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="上传图片2">
                                                <el-upload
                                                        class="avatar-uploader"
                                                        action="/file/avatarUpload"
                                                        :auto-upload="autoUpload"
                                                        name="imgFile"
                                                        :show-file-list="false"
                                                        :on-success="handleAvatarSuccessTwo"
                                                        :before-upload="beforeAvatarUpload">
                                                    <img v-if="imageUrl2" :src="imageUrl2" class="avatar">
                                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                                </el-upload>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="上传图片3">
                                                <el-upload
                                                        class="avatar-uploader"
                                                        action="/file/avatarUpload"
                                                        :auto-upload="autoUpload"
                                                        name="imgFile"
                                                        :show-file-list="false"
                                                        :on-success="handleAvatarSuccessThree"
                                                        :before-upload="beforeAvatarUpload">
                                                    <img v-if="imageUrl3" :src="imageUrl3" class="avatar">
                                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                                </el-upload>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="上传图片4">
                                                <el-upload
                                                        class="avatar-uploader"
                                                        action="/file/avatarUpload"
                                                        :auto-upload="autoUpload"
                                                        name="imgFile"
                                                        :show-file-list="false"
                                                        :on-success="handleAvatarSuccessFour"
                                                        :before-upload="beforeAvatarUpload">
                                                    <img v-if="imageUrl4" :src="imageUrl4" class="avatar">
                                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                                </el-upload>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="上传图片5">
                                                <el-upload
                                                        class="avatar-uploader"
                                                        action="/file/avatarUpload"
                                                        :auto-upload="autoUpload"
                                                        name="imgFile"
                                                        :show-file-list="false"
                                                        :on-success="handleAvatarSuccessFive"
                                                        :before-upload="beforeAvatarUpload">
                                                    <img v-if="imageUrl5" :src="imageUrl5" class="avatar">
                                                    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                                </el-upload>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="车辆待赔付金额">
                                                <el-input v-model="formData.compensationAmount"/>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="还车状态">
                                                <el-select v-model="formData.returnState">
                                                    <el-option label="未还车" value="0"></el-option>
                                                    <el-option label="已还车" value="1"></el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item label="实际租车时间">
                                                <!--       在el-for中添加时间模块       -->
                                                <el-date-picker type="datetime" placeholder="选择日期" v-model="formData.trueOrderDate"
                                                                style="width: 100%;" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item label="实际还车时间">
                                                <!--       在el-for中添加时间模块       -->
                                                <el-date-picker type="datetime" placeholder="选择日期" v-model="formData.trueReturnDate"
                                                                style="width: 100%;" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                                            </el-form-item>
                                        </el-col>

                                    </el-row>

                                </el-form>
                            </el-tab-pane>
                        </el-tabs>
                    </template>
                    <div slot="footer" class="dialog-footer">
                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>
                        <el-button type="primary" @click="handleUpdate()">确定</el-button>
                    </div>
                </el-dialog>
            </div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    var vue = new Vue({
        el: '#app',
        data:{
            autoUpload:true,//自动上传
            imageUrl1:null,//模型数据，用于上传图片完成后图片预览
            imageUrl2:null,//模型数据，用于上传图片完成后图片预览
            imageUrl3:null,//模型数据，用于上传图片完成后图片预览
            imageUrl4:null,//模型数据，用于上传图片完成后图片预览
            imageUrl5:null,//模型数据，用于上传图片完成后图片预览
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关模型数据
                pageIndex: 1,//当前页码
                pageSize: 10,//每页显示的记录数
                total: 0,//总记录数
                orderId: '', //订单编号
                memberName: "",//下单人
                phoneNumber: "",//下单手机号
                carName:""//车辆名称
            },
            dataList: [],//当前页要展示的分页列表数据
            formData: {
                returnImageone:"",
                returnImagetwo:"",
                returnImagethree:"",
                returnImagefour:"",
                returnImagefive:"",
            },//表单数据
            dialogFormVisible4Edit:false,//编辑表单是否可见
        },
        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.findPage();
        },
        methods: {
            //文件上传成功后的钩子，response为服务端返回的值，file为当前上传的文件封装成的js对象
            handleAvatarSuccessOne(response, file) {
                this.imageUrl1="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;
                this.formData.returnImageone="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;//保存，用于提交到数据库

            },
            handleAvatarSuccessTwo(response, file) {
                this.imageUrl2="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;
                this.formData.returnImagetwo="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;//保存，用于提交到数据库
            },
            handleAvatarSuccessThree(response, file) {
                this.imageUrl3="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;
                this.formData.returnImagethree="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;//保存，用于提交到数据库
            },
            handleAvatarSuccessFour(response, file) {
                this.imageUrl4="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;
                this.formData.returnImagefour="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;//保存，用于提交到数据库
            },
            handleAvatarSuccessFive(response, file) {
                this.imageUrl5="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;
                this.formData.returnImagefive="https://carrent-1309694167.cos.ap-beijing.myqcloud.com/"+response.data.key;//保存，用于提交到数据库
            },
            //上传图片之前执行
            beforeAvatarUpload(file) {
                const isJPG = file.type === 'image/jpeg';
                const isLt2M = file.size / 1024 / 1024 < 2;
                if (!isJPG) {
                    this.$message.error('上传套餐图片只能是 JPG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传套餐图片大小不能超过 2MB!');
                }
                return isJPG && isLt2M;
            },

                // 编辑订单
                handleUpdate () {
                    axios.post("/tReturncar/returnUpload",this.formData).then(resp =>{
                        console.log(resp);
                        if (resp.data.flag){
                            //弹出提示信息
                            this.$message({
                                message: resp.data.message,
                                type: 'success'
                            });
                            this.dialogFormVisible4Edit=false;
                            this.findPage();
                        }else{
                            console.log('失败');
                            //弹出失败信息
                            this.$message().error(resp.data.message);
                        }
                    })
                },

            //分页查询
            findPage() {
                axios.post("/tReturncar/selectPage",this.pagination)
                // {pageSize: this.pagination.pageSize, pageIndex: this.pagination.currentPage,orderId:this.pagination.orderId}
                    .then((res) => {
                    console.log(res);
                    this.dataList=res.data.data.page.list;
                    this.pagination.total=res.data.data.page.totalCount;

                })
            },
            //重置表单
            resetForm() {
                this.formData={};
            },
            //弹出编辑窗口
            handleEdit(row) {
                console.log(row);
                this.resetForm();
                this.dialogFormVisible4Edit=true;
                this.formData=row;
                this.imageUrl1=row.returnImageone;
                this.imageUrl2=row.returnImagetwo;
                this.imageUrl3=row.returnImagethree;
                this.imageUrl4=row.returnImagefour;
                this.imageUrl5=row.returnImagefive;

            },
            //切换页码显示分页信息
            handleCurrentChange(val) {
                this.pagination.pageIndex = val
                this.findPage()
            },
            //调整每页记录数
            handleSizeChange(val) {
                this.pagination.pageSize = val
                this.findPage()
            },
        }
    })
</script>
</html>